﻿define(
    [
        'durandal/app',
        'services/logger'
    ],
    function (app, logger) {
        var id = ko.observable(),
            name = ko.observable();
        ///
        ///  CONSTRUCTOR
        ///
        var organisationDetail = function () {
            this.displayName = 'Organisation Detail';
            this.id = id;
            this.name = name;
            
            //register events for this page
            app.on('organisation:select').then(organisationDetail.prototype.showOrganisation);
        };

        ///
        ///  PROTOTYPES
        ///
        organisationDetail.prototype = {
            viewAttached: function (view) {
                //you can get the view after it's bound and connected to it's parent dom node if you want
                logger.log('Organisation Detail is attached...', null, null, true);
            },
            showOrganisation: function (item) {
                id(item.Id);
                name(item.Name);
            },
            detailClick: function () {
                logger.log('Detail click...', null, null, true);
            }
        };

        return organisationDetail;
    });